#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
const int N=1e3+10;


vector<pair<int,int>> edge[N];
int n,m1,m2;
int dist[N];
int st[N];
int cnt[N];
bool spfa(int sz)
{
	memset(st,0,sizeof(st));
	memset(cnt,0,sizeof(cnt));
	memset(dist,0x3f3f3f3f,sizeof(dist));
	queue<int> q;
	for(int i=1;i<=sz;i++)
	{
		st[i]=1;
		dist[i]=0;
		q.push(i);
	}
	while(q.size())
	{
		int x=q.front();
		q.pop();
		st[x]=0;
		for(auto& e:edge[x])
		{
			int y=e.first;
			int w=e.second;
			if(dist[y]>dist[x]+w)
			{
				dist[y]=dist[x]+w;
				cnt[y]=cnt[x]+1;
				if(cnt[y]==n)
					return false;
				if(!st[y])
				{
					q.push(y);
					st[y]=1;
				}
			}
		}
	}
	return true;
}
int main()
{
	cin>>n>>m1>>m2;
	for(int i=1;i<n;i++)
	{
		edge[i+1].push_back({i,0});
	}
	
	for(int i=0;i<m1;i++)
	{
		int a,b,l;
		scanf("%d%d%d",&a,&b,&l);
		edge[a].push_back({b,l});
	}
	for(int i=0;i<m2;i++)
	{
		int a,b,d;
		scanf("%d%d%d",&a,&b,&d);
		edge[b].push_back({a,-d});		
	}
	if(!spfa(n))
	{
		cout<<-1<<endl;
	}
	else{
		spfa(1);
		if(dist[n]==0x3f3f3f3f)
			cout<<-2<<endl;
		else 
			cout<<dist[n]<<endl;
	}
	return 0;
}
//i<=i+1+0
//b-a<=l  b<=a+l
//b-a>=d  a<=b-d
